﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Security.Claims;
using W.Warehouse.Api.Application.Command.WarehouseCommand;
using W.Warehouse.Domain;
using W.Warehouse.Domain.DTO;
using W.Warehouse.Read.Api.Application.Command.WarehouseCommands;
using W.Warehouse.Repository.Interface;

namespace W.Warehouse.Read.Api.Controllers
{
    /// <summary>
    /// 仓库管理列表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class WarehouseMangeController : ControllerBase
    {
        private readonly IMediator _mediator;
        public WarehouseMangeController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 显示仓库类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<WarehouseType>>> GetWarehouseTypes()
        {
            return await _mediator.Send(new WarehouseGetTypesCommand());
        }
        /// <summary>
        /// 仓库查询显示分页
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<WarehousePageDTO>> GetWarehouse([FromQuery]WarehouseSelectCommand warehouse)
        {
            return await _mediator.Send(warehouse);
        }
        /// <summary>
        /// 反填仓库管理
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<WarehouseInfo>> FanWarehouseInfo([FromQuery] WarehouseFanCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
